package com.nanoso.service.jms;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;

import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;

import com.nanoso.service.jms.util.JmsFactory;

public class JmsSendService {
	private JmsTemplate jmsTemplate;

	public void setJmsTemplate(JmsTemplate jmsTemplate) {
		this.jmsTemplate = jmsTemplate;
	}

	public void sendMessage(final Object obj) {
		this.jmsTemplate.send(new MessageCreator() {

			@Override
			public Message createMessage(Session session) throws JMSException {

				Message message = JmsFactory.makeDealUrlMessage(session, obj);

				return message;
			}
		});
	}
}
